package com.scuec.groupfive.mapper;

import com.scuec.groupfive.entity.TaskQuestion;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface TaskQuestionMapper {
    @Insert("INSERT INTO task_questions (task_id, question_id, is_completed) " +
            "VALUES (#{taskId}, #{questionId}, #{isCompleted})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(TaskQuestion taskQuestion);

    @Insert("<script>" +
            "INSERT INTO task_questions (task_id, question_id, is_completed) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.taskId}, #{item.questionId}, #{item.isCompleted})" +
            "</foreach>" +
            "</script>")
    int batchInsert(@Param("list") List<TaskQuestion> taskQuestions);
}